# 该模块实现app的抽取
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from redis import StrictRedis
from flask_wtf import CSRFProtect
from flask_session import Session
from config import config_dict

db=SQLAlchemy()
redis_store=None

def create_app():
    app=Flask(__name__)
    config_class=config_dict['development']
    app.config.from_object(config_class)

    db.init_app(app)
    global redis_store
    redis_store=StrictRedis(host=config_class.REDIS_HOST,port=config_class.REDIS_PORT,decode_responses=True)

    CSRFProtect(app)
    Session(app)
    return app